<?php
session_start(); 
if(!isset($_SESSION['userName'])){
header( 'location:../index.php' ); 
}
include("../conf/connect.php");
	$serial=$_GET['serial']; 
	$user_id = $_SESSION['user_id'];
	$hid = $_SESSION['usrHHid'];
	$resId =$_SESSION['lid'];
	 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
	<link rel="shortcut icon" href="images/favicon.ico" />
</head>
<body class="iub_back">
<?php if($serial=='a'){
	$sql="SELECT cod1 from cod WHERE id='$resId' and user_id='$user_id' and hid = '$hid'";
	$result= mysql_query($sql) or die ("problem 2ND BLOCK OF RESPONDENT");
	$row = mysql_fetch_assoc($result);
?>
	<form action="answer.php?qus=5_a" method="post">
	<table align="center" class="table_border" >
		<tr align="left">
				<td align="left" valign="top"> Section COD:</td>
		</tr>
		<tr align="left">
				<td align="left" valign="top">COD01: Did anyone die (last mnth) ?</td>
		</tr>
		<tr align="left">
				<td align="left" <?php if($row['cod1'] == ''||$row['cod1'] == '0'){?>bgcolor="#F7A244"<?php }?>>
					<select name="cod1">
						 <?php
								if($row['cod1'] == ''||$row['cod1'] == '0'){
								 echo "<option value='0' selected='selected'> Select</option>";
								}
								else{
									$hop=$row['cod1'];
									$sql1="SELECT value from retreive_data WHERE qus='heh01_a' and hoption='$hop' ";
									$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
									$value = mysql_fetch_assoc($result1);
									$mv= $value['value'];
									echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
								}
							?>
						<option value="1">1-Yes</option>
						<option value="3">3-No</option>
					</select>					
				</td>
		</tr>
		<tr>
				<td  align="right">
					<input type="submit" value="Next" class="input-box" />&nbsp;
				</td>
		</tr>
	</table>
	</form>
<?php }?>
<?php if($serial=='b'){?>
	<form method="post" action="answer.php?qus=5_b">
		<table align="center" class="table_border">
			<tr align="left">
					<td align="left">COD01a. Name :</td>
			</tr>
			<tr align="left">
					<td align="left"><input type="text" name="data[name]" value="None" /></td>
			</tr>
			<tr>
					<td  align="right"><input type="submit" value="Continue"  class="input-box"/><input name="done" type="submit" value="Done" class="input-box" /></td>
			</tr>
			
		</table>
	</form>
<?php }?>
	
<?php if($serial=='c'){
		$id=$_GET['id'];
		$sql="SELECT q2, q3, q4, q5, q6, q7, q8, cod09, cod10, cod11, cod12, cod13, cod14, cod15, cod16 from cod  WHERE id='$resId' and user_id='$user_id' and hid = '$hid'";
		$result= mysql_query($sql) or die ("problem 2ND BLOCK OF RESPONDENT");
		$row = mysql_fetch_assoc($result);
		//echo "<pre>";
		//print_r($row );
?>	
	<form method="post" action="answer.php?qus=5_c">
	<input type="hidden" name="id" value="<?php echo $id;?>" />
		<table align="center" class="table_border" >
			<tr align="left">
					<td align="left">COD02. Age :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['q2'] == '00'){?>bgcolor="#F7A244"<?php }?>>
						<select name="data[1st]">
							<?php 
							for($i=0;$i<10;$i++){
							?>
							<option value="<?php echo $i;?>" <?php if($row['q2'][0] == $i ){?> selected="selected" <?php }?>><?php echo $i;?></option>
							<?php
							}
							?>
						</select> 
						<select name="data[2nd]">
							<?php 
							for($i=0;$i<10;$i++){
							?>
							<option value="<?php echo $i;?>" <?php if($row['q2'][1] == $i ){?> selected="selected" <?php }?>><?php echo $i;?></option>
							<?php
							}
							?>
						</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD03. Sex :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['q3'] == ''){?>bgcolor="#F7A244"<?php }?>>
						<input type="radio" name="sex" value="1" <?php if($row['q3'] == 1){?>checked="checked" <?php }?>/> Male<br />
						<input type="radio" name="sex" value="3" <?php if($row['q3'] == 3){?>checked="checked" <?php }?>/> Female
						
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD04. Marital Status :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['q4'] == ''){?>bgcolor="#F7A244"<?php }?>>
						<input type="radio" name="mstat" value="01" <?php if($row['q4'] == 01){?>checked="checked" <?php }?> /> 01-Unmarried<br />
						<input type="radio" name="mstat" value="02" <?php if($row['q4'] == 02){?>checked="checked" <?php }?>/> 02-Married<br />
						<input type="radio" name="mstat" value="03" <?php if($$row['q4'] == 03){?>checked="checked" <?php }?>/> 03-Separated<br />
						<input type="radio" name="mstat" value="04" <?php if($row['q4'] == 04){?>checked="checked" <?php }?>/> 04-Divorced<br />
						<input type="radio" name="mstat" value="05" <?php if($row['q4'] == 05){?>checked="checked" <?php }?>/> 05-Widowed
						 
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD05. Reltn w HHH :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['q5'] == ''){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[relation]">
								<?php
									if($row['q5'] == ''){
									 echo "<option value='00' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['q5'];
										$sql1="SELECT value from retreive_data WHERE qus='q5' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="00" > Select</option>
								<option value="01"> 01-Self</option>
								<option value="02"> 02-Husband</option>
								<option value="03"> 03-Wife</option>
								<option value="04"> 04-Son</option>
								<option value="05"> 05-Daughter</option>
								<option value="06"> 06-Step Son</option>
								<option value="07"> 07-Step Daughter</option>
								<option value="08"> 08-Adopted Son</option>
								<option value="09"> 09-Adopted daughter</option>
								<option value="10"> 10-Father</option>
								<option value="11"> 11-Mother</option>
								<option value="12"> 12-Step Father</option>
								<option value="13"> 13-Step Mother</option>
								<option value="14"> 14-Brother</option>
								<option value="15"> 15-Sister</option>
								<option value="16"> 16-Step Brother</option>
								<option value="17"> 17-Step Sister</option>
								<option value="18"> 18-Adopted Brother</option>
								<option value="19"> 19-Adopted Sister</option>
								<option value="20"> 20-Fathr-in-law</option>
								<option value="21"> 21-Mothr-in-law</option>
								<option value="22"> 22-Son-in-law</option>
								<option value="23"> 23-Daughtr-in-law</option>
								<option value="24"> 24-Young Sis Husbnd</option>
								<option value="25"> 25-Elder Sis Husbnd</option>
								<option value="26"> 26-</option>
								<option value="27"> 27-Elder Brother</option>
								<option value="28"> 28-Brothr-in-law</option>
								<option value="29"> 29-Sistr-in-law</option>
								<option value="30"> 30-</option>
								<option value="31"> 31-Elder Brther's wife</option>
								<option value="32"> 32-Young Brther's wife</option>
								<option value="33"> 33-Son's son</option>
								<option value="34"> 34-Daughter's son</option>
								<option value="35"> 35-Matrnl Grndfther</option>
								<option value="36"> 36-Matrnl Grndmther</option>
								<option value="37"> 37-Step matrnl Grndfathr</option>
								<option value="38"> 38-Step matrnl Grndmothr</option>
								<option value="39"> 39-Patrnl Grndfther</option>
								<option value="40"> 40-Patrnl Grndmther</option>
								<option value="41"> 41-Step Patrnl Grndfther</option>
								<option value="42"> 42-Step Pat. Grandmother</option>
								<option value="43"> 43-Matrnl Uncle</option>
								<option value="44"> 44-Matrnl uncle wife</option>
								<option value="45"> 45-Mother's sister</option>
								<option value="46"> 46-Mother's sis hsbnd</option>
								<option value="47"> 47-Elder Uncle</option>
								<option value="48"> 48-Elder Aunt</option>
								<option value="49"> 49-Youngr uncle</option>
								<option value="50"> 50-Youngr aunt</option>
								<option value="51"> 51-Father's Sister</option>
								<option value="52"> 52-Father's Sis Hsbnd</option>
								<option value="53"> 53-Patrnl-cousin bro</option>
								<option value="54"> 54-Patrnl-cousin sis</option>
								<option value="55"> 55-Matrnl-cousin bro</option>
								<option value="56"> 56-Matrnl-cousin sis</option>
								<option value="57"> 57-Mothr's Sis son</option>
								<option value="58"> 58-Mothr's Sis daught</option>
								<option value="59"> 59-Fathr's Sis son</option>
								<option value="60"> 60-Fathr's Sis daughtr</option>
								<option value="61"> 61-Brthr's son</option>
								<option value="62"> 62-Brthr's daughtr</option>
								<option value="63"> 63-Sistr's son</option>
								<option value="64"> 64-Sistr's daughtr</option>
								<option value="65"> 65-Great grndson</option>
								<option value="66"> 66-Great grnd-daughtr</option>
								<option value="67"> 67-</option>
								<option value="68"> 68-</option>
								<option value="69"> 69-Hsbnd's young bro.</option>
								<option value="70"> 70-Hsbnd's young sis</option>
								<option value="71"> 71-</option>
								<option value="72"> 72-</option>
								<option value="73"> 73-</option>
								<option value="74"> 74-</option>
								<option value="75"> 75-Servant(Male)</option>
								<option value="76"> 76-Servant(Female)</option>
								<option value="77"> 77-Other</option>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD06. Schl Type :</td>
			</tr>
			<tr align="left">
					<td align="left"> 
						<select name="data[st]">
							<option value="01">01-None</option>
							<option value="02">02-Maktab</option>
							<option value="03">03-Madrasa</option>
							<option value="04">04-School/College</option>
							<option value="05">05-Brac</option>
						</select> 
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD07. Yrs of Schlng :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['q6'] == '00'){?>bgcolor="#F7A244"<?php }?>> 
						<select name="data[s1]">
							<?php 
							for($i=0;$i<10;$i++){
							?>
							<option value="<?php echo $i;?>" <?php if($row['q6'][0] == $i ){?> selected="selected" <?php }?>><?php echo $i;?></option>
							<?php
							}
							?>
						</select> 
						<select name="data[s2]">
							<?php 
							for($i=0;$i<10;$i++){
							?>
							<option value="<?php echo $i;?>" <?php if($row['q6'][1] == $i ){?> selected="selected" <?php }?>><?php echo $i;?></option>
							<?php
							}
							?>
						</select>
					</td>
			</tr>			
			<tr align="left">
					<td align="left">COD08. Occupation :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['q7'] == ''){?>bgcolor="#F7A244"<?php }?>> 
							<input type="text" name="data[occupation]" />
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD09. Used Tobacco :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod09'] == ''){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod09]">
								<?php
									if($row['cod09'] == ''){
									 echo "<option value='00' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod09'];
										$sql1="SELECT value from retreive_data WHERE qus='cod09' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="1"> 1-Yes</option>
								<option value="2"> 2-No</option>
								<option value="9"> 9-Don't know</option>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD10. Cause of death :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod10'] == ''){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod10]">
								<?php
									if($row['cod10'] == ''){
									 echo "<option value='00' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod10'];
										$sql1="SELECT value from retreive_data WHERE qus='cod10' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<?php for($i=1;$i<=6;$i++){
											$hop=$i;
											$sql1="SELECT value from retreive_data WHERE qus='cod10' and hoption='$hop' ";
											$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
											$value = mysql_fetch_assoc($result1);
											$mv= $value['value'];
											echo "<option value='$hop'> $hop-$mv</option>";
									} ?>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD11. HyperTensn :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod11'] == ''){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod11]">
								<?php
									if($row['cod11'] == ''){
									 echo "<option value='00' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod11'];
										$sql1="SELECT value from retreive_data WHERE qus='cod09' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="1"> 1-Yes</option>
								<option value="2"> 2-No</option>
								<option value="9"> 9-Don't know</option>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD12. Stroke :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod12'] == ''||$row['cod12'] == '0'){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod12]">
								<?php
									if($row['cod12'] == ''){
									 echo "<option value='0' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod12'];
										$sql1="SELECT value from retreive_data WHERE qus='cod09' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="1"> 1-Yes</option>
								<option value="2"> 2-No</option>
								<option value="9"> 9-Don't know</option>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD13. DM :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod13'] == ''||$row['cod13'] == '0'){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod13]">
								<?php
									if($row['cod13'] == ''){
									 echo "<option value='0' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod13'];
										$sql1="SELECT value from retreive_data WHERE qus='cod09' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="1"> 1-Yes</option>
								<option value="2"> 2-No</option>
								<option value="9"> 9-Don't know</option>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD14. Heart Disease :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod14'] == ''||$row['cod14'] == '0'){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod14]">
								<?php
									if($row['cod14'] == ''){
									 echo "<option value='0' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod14'];
										$sql1="SELECT value from retreive_data WHERE qus='cod09' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="1"> 1-Yes</option>
								<option value="2"> 2-No</option>
								<option value="9"> 9-Don't know</option>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD15. T.B. :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod15'] == ''||$row['cod15'] == '0'){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod15]">
								<?php
									if($row['cod15'] == ''){
									 echo "<option value='0' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod15'];
										$sql1="SELECT value from retreive_data WHERE qus='cod09' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="1"> 1-Yes</option>
								<option value="2"> 2-No</option>
								<option value="9"> 9-Don't know</option>
							</select>
					</td>
			</tr>
			<tr align="left">
					<td align="left">COD16. Cancer :</td>
			</tr>
			<tr align="left">
					<td align="left" <?php if($row['cod16'] == ''||$row['cod16'] == '0'){?>bgcolor="#F7A244"<?php }?>>
							<select name="data[cod16]">
								<?php
									if($row['cod16'] == ''){
									 echo "<option value='0' selected='selected'> Select</option>";
									}
									else{
										$hop=$row['cod16'];
										$sql1="SELECT value from retreive_data WHERE qus='cod09' and hoption='$hop' ";
										$result1= mysql_query($sql1) or die ("problem 2ND BLOCK OF RESPONDENT");
										$value = mysql_fetch_assoc($result1);
										$mv= $value['value'];
										echo "<option value='$hop' selected='selected'> $hop-$mv</option>";
									}
								?>
								<option value="1"> 1-Yes</option>
								<option value="2"> 2-No</option>
								<option value="9"> 9-Don't know</option>
							</select>
					</td>
			</tr>
			<tr>
					<td align="right">
						<input type="submit" value="Next" class="input-box" />&nbsp;
					</td>
			</tr>
			
		</table>
	</form>
<?php }?>
</body>
</html>